--
-- Author: shunguo.chen
-- Date: 2018-10-22 11:50:11
--
-- PayVo 支付项

local fileName = string.getModeName(...)
local ClassRef = class(fileName)

function ClassRef:ctor(data)
	if data then
		self:init(data)
	end
end

-- data = recharge conf
function ClassRef:init(data)
	self._conf = data

	self.id = tonumber(data.ID)
	
	self.price = data.price

	self.diamond = tonumber(data.demond)
	self.extraDiamond = tonumber(data.extraGift or "0") or 0
	self.firstExtraDiamond = tonumber(data.firstExtraGift or "0") or 0
	self.isHot = (data.hotGoods == "1")

	self.product_id = tostring(data.product_id or "")
	self._isFirst = false
end

-- 使用SDK平台的运营数据
-- {
--     "ex_send" = {
--     }
--     "num"       = "60"
--     "send_ext"  = ""
--     "send_num"  = "6"
--     "send_rate" = "0"
--     "send_type" = "2"
--     "single_ex" = {
--         1 = {
--             "ex_send" = {
--             }
--             "num"       = "60"
--             "send_ext"  = "限1次"
--             "send_num"  = "60"
--             "send_rate" = "0"
--             "send_type" = "2"
--         }
--     }
-- }
function ClassRef:initSDKData(mpInfo)
	if not mpInfo then return end

	local single_ex = mpInfo.single_ex
	self._isFirst = (single_ex ~= nil)
	if mpInfo.send_num then
		self.extraDiamond = tonumber(mpInfo.send_num)
	end
	if single_ex and single_ex[1] and single_ex[1].send_num then
		self.firstExtraDiamond = tonumber(single_ex[1].send_num)
	end
end

function ClassRef:setIsFirst(b)
	self._isFirst = b
end

function ClassRef:isFirst()
	return self._isFirst
end

function ClassRef:isOpen()
	return UD:isPayOpen()
end

-- function ClassRef:setIsFirst(b)
--     self._isFirst = b
-- end

-- function ClassRef:isFirst()
-- 	return self._isFirst
-- end

-- function ClassRef:getExtraDiamond()
-- 	if self._isFirst then
--         return self.firstExtraDiamond, true
--     else
-- 		return self.extraDiamond, false
-- 	end
-- end

function ClassRef:getIcon()
	if not self._icon then
		self._icon = string.format("art/recharge_icon/%s.png", self._conf.icon)
	end
	return self._icon
end

return ClassRef